/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package appClientHandler;

import java.io.Serializable;

/**
 *
 * eCOM - Adopte un Presta - Mars-Avril 2013
 * @author Kheira, Jef, William, Tuan-Long
 */
public class LoginResult implements Serializable 
{
    	public static final LoginResult ERROR = new LoginResult("Erreur d'authentification",
								LoginResultCode.UNKNOWN,
								null);
        
	private final String message;
	private final LoginResultCode loginResultCode;
	private final LoginIdentity identity;
	
	public LoginResult(String message, LoginResultCode loginResultCode, LoginIdentity identity) {
		this.message = message;
		this.loginResultCode = loginResultCode;
		this.identity = identity;
	}

	public LoginResultCode getLoginResultCode() {
		return loginResultCode;
	}

	public LoginIdentity getIdentity() {
		return identity;
	}

	public String getMessage() {
		return message;
	}

	public boolean hasIdentity() {
		return getIdentity() != null;
	}

	public boolean isValid() {
		return loginResultCode.equals(LoginResultCode.SUCCESS);
	}
}
